<?php

/**
 * abet actions.
 *
 * @package    sfproject
 * @subpackage abet
 * @author     Your name here
 */
class abetActions extends sfActions
{

////////////////////////////////////// student///////////////////////////////

public function executeIndexStudent(sfWebRequest $request)
  {
    $this->Abetstudents = AbetStudentPeer::doSelect(new Criteria());
  }

  public function executeShowStudent(sfWebRequest $request)
  {
    $this->Abetstudent = AbetStudentPeer::retrieveByPk($request->getParameter('stu_code'));
    $this->forward404Unless($this->Abetstudent);
  }

  public function executeNewStudent(sfWebRequest $request)
  {
    $this->form = new AbetstudentForm();
  }

  public function executeCreateStudent(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST));

    $this->form = new AbetstudentForm();

    $this->processFormStudent($request, $this->form);

    $this->setTemplate('newStudent');
  }

  public function executeEditStudent(sfWebRequest $request)
  {
    $this->forward404Unless($Abetstudent = AbetStudentPeer::retrieveByPk($request->getParameter('stu_code')), sprintf('Object Abetstudent does not exist (%s).', $request->getParameter('stu_code')));
    $this->form = new AbetstudentForm($Abetstudent);
  }

  public function executeUpdateStudent(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
    $this->forward404Unless($Abetstudent = AbetStudentPeer::retrieveByPk($request->getParameter('stu_code')), sprintf('Object Abetstudent does not exist (%s).', $request->getParameter('stu_code')));
    $this->form = new AbetstudentForm($Abetstudent);

    $this->processFormStudent($request, $this->form);

    $this->setTemplate('edit');
  }

  public function executeDeleteStudent(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->forward404Unless($Abetstudent = AbetStudentPeer::retrieveByPk($request->getParameter('stu_code')), sprintf('Object Abetstudent does not exist (%s).', $request->getParameter('stu_code')));
    $Abetstudent->delete();

    $this->redirect('abet/indexStudent');
  }

  protected function processFormStudent(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $Abetstudent = $form->save();

      $this->redirect('abet/editStudent?stu_code='.$Abetstudent->getStuCode());
    }
  }


//////////////////////////////////////team //////////////////////////////////


  public function executeIndexTeam(sfWebRequest $request)
  {
    $this->Abetteams = AbetTeamPeer::doSelect(new Criteria());
  }

  public function executeShowTeam(sfWebRequest $request)
  {
    $this->Abetteam = AbetTeamPeer::retrieveByPk($request->getParameter('team_id'));
    $this->forward404Unless($this->Abetteam);
  }

  public function executeNewTeam(sfWebRequest $request)
  {
    $this->form = new AbetteamForm();
  }

  public function executeCreateTeam(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST));

    $this->form = new AbetteamForm();

    $this->processFormTeam($request, $this->form);

    $this->setTemplate('newTeam');
  }

  public function executeEditTeam(sfWebRequest $request)
  {
    $this->forward404Unless($Abetteam = AbetTeamPeer::retrieveByPk($request->getParameter('team_id')), sprintf('Object Abetteam does not exist (%s).', $request->getParameter('team_id')));
    $this->form = new AbetteamForm($Abetteam);
  }

  public function executeUpdateTeam(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
    $this->forward404Unless($Abetteam = AbetTeamPeer::retrieveByPk($request->getParameter('team_id')), sprintf('Object Abetteam does not exist (%s).', $request->getParameter('team_id')));
    $this->form = new AbetteamForm($Abetteam);

    $this->processFormTeam($request, $this->form);

    $this->setTemplate('editTeam');
  }

  public function executeDeleteTeam(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->forward404Unless($Abetteam = AbetTeamPeer::retrieveByPk($request->getParameter('team_id')), sprintf('Object Abetteam does not exist (%s).', $request->getParameter('team_id')));
    $Abetteam->delete();

    $this->redirect('abet/indexTeam');
  }

  protected function processFormTeam(sfWebRequest $request, sfForm $form)
  {

    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $Abetteam = $form->save();

      $this->redirect('abet/editTeam?team_id='.$Abetteam->getTeamId());
    }
  }

////////////////////////////////////////// instructor ///////////////////////////////


public function executeIndexInstructor(sfWebRequest $request)
  {
    $this->AbetInstructors = AbetInstructorPeer::doSelect(new Criteria());
  }

  public function executeShowInstructor(sfWebRequest $request)
  {
    $this->AbetInstructor = AbetInstructorPeer::retrieveByPk($request->getParameter('ins_code'));
    $this->forward404Unless($this->AbetInstructor);
  }

  public function executeNewInstructor(sfWebRequest $request)
  {
    $this->form = new AbetInstructorForm();
  }

  public function executeCreateInstructor(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST));

    $this->form = new AbetInstructorForm();

    $this->processFormInstructor($request, $this->form);

    $this->setTemplate('newInstructor');
  }

  public function executeEditInstructor(sfWebRequest $request)
  {
    $this->forward404Unless($AbetInstructor = AbetInstructorPeer::retrieveByPk($request->getParameter('ins_code')), sprintf('Object AbetInstructor does not exist (%s).', $request->getParameter('ins_code')));
    $this->form = new AbetInstructorForm($AbetInstructor);
  }

  public function executeUpdateInstructor(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
    $this->forward404Unless($AbetInstructor = AbetInstructorPeer::retrieveByPk($request->getParameter('ins_code')), sprintf('Object AbetInstructor does not exist (%s).', $request->getParameter('ins_code')));
    $this->form = new AbetInstructorForm($AbetInstructor);

    $this->processFormInstructor($request, $this->form);

    $this->setTemplate('editInstructor');
  }

  public function executeDeleteInstructor(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->forward404Unless($AbetInstructor = AbetInstructorPeer::retrieveByPk($request->getParameter('ins_code')), sprintf('Object AbetInstructor does not exist (%s).', $request->getParameter('ins_code')));
    $AbetInstructor->delete();

    $this->redirect('abet/indexInstructor');
  }

  protected function processFormInstructor(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $AbetInstructor = $form->save();

      $this->redirect('abet/edit?ins_code='.$AbetInstructor->getInsCode());
    }
  }


/////////////////////////////////////////// college /////////////////////////////////


 public function executeIndexCollege(sfWebRequest $request)
  {
    $this->AbetColleges = AbetCollegePeer::doSelect(new Criteria());
  }

  public function executeShowCollege(sfWebRequest $request)
  {
    $this->AbetCollege = AbetCollegePeer::retrieveByPk($request->getParameter('col_code'),
                           $request->getParameter('ins_code'));
    $this->forward404Unless($this->AbetCollege);
  }

  public function executeNewCollege(sfWebRequest $request)
  {
    $this->form = new AbetCollegeForm();
  }

  public function executeCreateCollege(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST));

    $this->form = new AbetCollegeForm();

    $this->processFormCollege($request, $this->form);

    $this->setTemplate('newCollege');
  }

  public function executeEditCollege(sfWebRequest $request)
  {
    $this->forward404Unless($AbetCollege = AbetCollegePeer::retrieveByPk($request->getParameter('col_code'),
                     $request->getParameter('ins_code')), sprintf('Object AbetCollege does not exist (%s).', $request->getParameter('col_code'),
                     $request->getParameter('ins_code')));
    $this->form = new AbetCollegeForm($AbetCollege);
  }

  public function executeUpdateCollege(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
    $this->forward404Unless($AbetCollege = AbetCollegePeer::retrieveByPk($request->getParameter('col_code'),
                     $request->getParameter('ins_code')), sprintf('Object AbetCollege does not exist (%s).', $request->getParameter('col_code'),
                     $request->getParameter('ins_code')));
    $this->form = new AbetCollegeForm($AbetCollege);

    $this->processFormCollege($request, $this->form);

    $this->setTemplate('editCollege');
  }

  public function executeDeleteCollege(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->forward404Unless($AbetCollege = AbetCollegePeer::retrieveByPk($request->getParameter('col_code'),
                     $request->getParameter('ins_code')), sprintf('Object AbetCollege does not exist (%s).', $request->getParameter('col_code'),
                     $request->getParameter('ins_code')));
    $AbetCollege->delete();

    $this->redirect('abet/indexCollege');
  }

  protected function processFormCollege(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $AbetCollege = $form->save();

      $this->redirect('abet/editCollege?col_code='.$AbetCollege->getColCode().'&ins_code='.$AbetCollege->getInsCode());
    }
  }


/////////////////////////////////////////////// project ///////////////////////////////////////////


public function executeIndexProject(sfWebRequest $request)
  {
    $this->AbetProjects = AbetProjectPeer::doSelect(new Criteria());
  }

  public function executeShowProject(sfWebRequest $request)
  {
    $this->AbetProject = AbetProjectPeer::retrieveByPk($request->getParameter('ins_code'),
                           $request->getParameter('proj_id'));
    $this->forward404Unless($this->AbetProject);
  }

  public function executeNewProject(sfWebRequest $request)
  {
    $this->form = new AbetProjectForm();
  }

  public function executeCreateProject(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST));

    $this->form = new AbetProjectForm();

    $this->processFormProject($request, $this->form);

    $this->setTemplate('newProject');
  }

  public function executeEditProject(sfWebRequest $request)
  {
    $this->forward404Unless($AbetProject = AbetProjectPeer::retrieveByPk($request->getParameter('ins_code'),
                     $request->getParameter('proj_id')), sprintf('Object AbetProject does not exist (%s).', $request->getParameter('ins_code'),
                     $request->getParameter('proj_id')));
    $this->form = new AbetProjectForm($AbetProject);
  }

  public function executeUpdateProject(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
    $this->forward404Unless($AbetProject = AbetProjectPeer::retrieveByPk($request->getParameter('ins_code'),
                     $request->getParameter('proj_id')), sprintf('Object AbetProject does not exist (%s).', $request->getParameter('ins_code'),
                     $request->getParameter('proj_id')));
    $this->form = new AbetProjectForm($AbetProject);

    $this->processFormProject($request, $this->form);

    $this->setTemplate('editProject');
  }

  public function executeDeleteProject(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->forward404Unless($AbetProject = AbetProjectPeer::retrieveByPk($request->getParameter('ins_code'),
                     $request->getParameter('proj_id')), sprintf('Object AbetProject does not exist (%s).', $request->getParameter('ins_code'),
                     $request->getParameter('proj_id')));
    $AbetProject->delete();

    $this->redirect('abet/indexProject');
  }

  protected function processFormProject(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $AbetProject = $form->save();

      $this->redirect('abet/editProject?ins_code='.$AbetProject->getInsCode().'&proj_id='.$AbetProject->getProjId());
    }
  }

//////////////////////////////////////////// project list /////////////////////////////////////////


  public function executeIndexProjectList(sfWebRequest $request)
  {
    $this->AbetProjectLists = AbetProjectListPeer::doSelect(new Criteria());
  }

  public function executeShowProjectList(sfWebRequest $request)
  {
    $this->AbetProjectList = AbetProjectListPeer::retrieveByPk($request->getParameter('proj_id'),
                   $request->getParameter('team_id'));
    $this->forward404Unless($this->AbetProjectList);
  }

  public function executeNewProjectList(sfWebRequest $request)
  {
    $this->form = new AbetProjectListForm();
  }

  public function executeCreateProjectList(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST));

    $this->form = new AbetProjectListForm();

    $this->processFormProjectList($request, $this->form);

    $this->setTemplate('newProjectList');
  }

  public function executeEditProjectList(sfWebRequest $request)
  {
    $this->forward404Unless($AbetProjectList = AbetProjectListPeer::retrieveByPk($request->getParameter('proj_id'),
             $request->getParameter('team_id')), sprintf('Object AbetProjectList does not exist (%s).', $request->getParameter('proj_id'),
             $request->getParameter('team_id')));
    $this->form = new AbetProjectListForm($AbetProjectList);
  }

  public function executeUpdateProjectList(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
    $this->forward404Unless($AbetProjectList = AbetProjectListPeer::retrieveByPk($request->getParameter('proj_id'),
             $request->getParameter('team_id')), sprintf('Object AbetProjectList does not exist (%s).', $request->getParameter('proj_id'),
             $request->getParameter('team_id')));
    $this->form = new AbetProjectListForm($AbetProjectList);

    $this->processFormProjectList($request, $this->form);

    $this->setTemplate('editProjectList');
  }

  public function executeDeleteProjectList(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->forward404Unless($AbetProjectList = AbetProjectListPeer::retrieveByPk($request->getParameter('proj_id'),
             $request->getParameter('team_id')), sprintf('Object AbetProjectList does not exist (%s).', $request->getParameter('proj_id'),
             $request->getParameter('team_id')));
    $AbetProjectList->delete();

    $this->redirect('abet/indexProjectList');
  }

  protected function processFormProjectList(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $AbetProjectList = $form->save();

      $this->redirect('abet/editProjectList?proj_id='.$AbetProjectList->getProjId().'&team_id='.$AbetProjectList->getTeamId());
    }
  }

////////////////////////////////////////////////////// project date //////////////////////

public function executeIndexProjectDate(sfWebRequest $request)
  {
    $this->AbetProjectDates = AbetProjectDatePeer::doSelect(new Criteria());
  }

  public function executeShowProjectDate(sfWebRequest $request)
  {
    $this->AbetProjectDate = AbetProjectDatePeer::retrieveByPk($request->getParameter('admin_id'),
                   $request->getParameter('date_code'));
    $this->forward404Unless($this->AbetProjectDate);
  }

  public function executeNewProjectDate(sfWebRequest $request)
  {
    $this->form = new AbetProjectDateForm();
  }

  public function executeCreateProjectDate(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST));

    $this->form = new AbetProjectDateForm();

    $this->processFormProjectDate($request, $this->form);

    $this->setTemplate('newProjectDate');
  }

  public function executeEditProjectDate(sfWebRequest $request)
  {
    $this->forward404Unless($AbetProjectDate = AbetProjectDatePeer::retrieveByPk($request->getParameter('admin_id'),
             $request->getParameter('date_code')), sprintf('Object AbetProjectDate does not exist (%s).', $request->getParameter('admin_id'),
             $request->getParameter('date_code')));
    $this->form = new AbetProjectDateForm($AbetProjectDate);
  }

  public function executeUpdateProjectDate(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
    $this->forward404Unless($AbetProjectDate = AbetProjectDatePeer::retrieveByPk($request->getParameter('admin_id'),
             $request->getParameter('date_code')), sprintf('Object AbetProjectDate does not exist (%s).', $request->getParameter('admin_id'),
             $request->getParameter('date_code')));
    $this->form = new AbetProjectDateForm($AbetProjectDate);

    $this->processFormProjectDate($request, $this->form);

    $this->setTemplate('editProjectDate');
  }

  public function executeDeleteProjectDate(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->forward404Unless($AbetProjectDate = AbetProjectDatePeer::retrieveByPk($request->getParameter('admin_id'),
             $request->getParameter('date_code')), sprintf('Object AbetProjectDate does not exist (%s).', $request->getParameter('admin_id'),
             $request->getParameter('date_code')));
    $AbetProjectDate->delete();

    $this->redirect('abet/indexProjectDate');
  }

  protected function processFormProjectDate(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $AbetProjectDate = $form->save();

      $this->redirect('abet/editProjectDate?admin_id='.$AbetProjectDate->getAdminId().'&date_code='.$AbetProjectDate->getDateCode());
    }
  }

/////////////////////////////////////////////// department ///////////////////////////////

  public function executeIndexDepartment(sfWebRequest $request)
  {
    $this->AbetDepartments = AbetDepartmentPeer::doSelect(new Criteria());
  }

  public function executeShowDepartment(sfWebRequest $request)
  {
    $this->AbetDepartment = AbetDepartmentPeer::retrieveByPk($request->getParameter('dep_code'),
                     $request->getParameter('ins_code'),
                     $request->getParameter('col_code'));
    $this->forward404Unless($this->AbetDepartment);
  }

  public function executeNewDepartment(sfWebRequest $request)
  {
    $this->form = new AbetDepartmentForm();
  }

  public function executeCreateDepartment(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST));

    $this->form = new AbetDepartmentForm();

    $this->processFormDepartment($request, $this->form);

    $this->setTemplate('newDepartment');
  }

  public function executeEditDepartment(sfWebRequest $request)
  {
    $this->forward404Unless($AbetDepartment = AbetDepartmentPeer::retrieveByPk($request->getParameter('dep_code'),
               $request->getParameter('ins_code'),
               $request->getParameter('col_code')), sprintf('Object AbetDepartment does not exist (%s).', $request->getParameter('dep_code'),
               $request->getParameter('ins_code'),
               $request->getParameter('col_code')));
    $this->form = new AbetDepartmentForm($AbetDepartment);
  }

  public function executeUpdateDepartment(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
    $this->forward404Unless($AbetDepartment = AbetDepartmentPeer::retrieveByPk($request->getParameter('dep_code'),
               $request->getParameter('ins_code'),
               $request->getParameter('col_code')), sprintf('Object AbetDepartment does not exist (%s).', $request->getParameter('dep_code'),
               $request->getParameter('ins_code'),
               $request->getParameter('col_code')));
    $this->form = new AbetDepartmentForm($AbetDepartment);

    $this->processFormDepartment($request, $this->form);

    $this->setTemplate('editDepartment');
  }

  public function executeDeleteDepartment(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->forward404Unless($AbetDepartment = AbetDepartmentPeer::retrieveByPk($request->getParameter('dep_code'),
               $request->getParameter('ins_code'),
               $request->getParameter('col_code')), sprintf('Object AbetDepartment does not exist (%s).', $request->getParameter('dep_code'),
               $request->getParameter('ins_code'),
               $request->getParameter('col_code')));
    $AbetDepartment->delete();

    $this->redirect('abet/indexDepartment');
  }

  protected function processFormDepartment(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $AbetDepartment = $form->save();

      $this->redirect('abet/editDepartment?dep_code='.$AbetDepartment->getDepCode().'&ins_code='.$AbetDepartment->getInsCode().'&col_code='.$AbetDepartment->getColCode());
    }
  }

}
